package com.itheima.app.controller;

import com.itheima.app.manager.MessageManager;
import com.itheima.vo.PageBeanVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MessageController {

    @Autowired
    private MessageManager messageManager;

    //点赞列表
    @GetMapping("/messages/likes")
    public PageBeanVo findLike(
            @RequestParam(value = "page", defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pagesize", defaultValue = "10") Integer pageSize) {

        //1. 确定操作类型
        Integer commentType = 1;

        //2. 调用manager查询
        return messageManager.findCommentList(commentType,pageNum,pageSize);
    }

    //评论列表
    @GetMapping("/messages/comments")
    public PageBeanVo findComment(
            @RequestParam(value = "page", defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pagesize", defaultValue = "10") Integer pageSize) {
        //1. 确定操作类型
        Integer commentType = 2;

        //2. 调用manager查询
        return messageManager.findCommentList(commentType,pageNum,pageSize);
    }


    //喜欢列表
    @GetMapping("/messages/loves")
    public PageBeanVo findLove(
            @RequestParam(value = "page", defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pagesize", defaultValue = "10") Integer pageSize) {

        //1. 确定操作类型
        Integer commentType = 3;

        //2. 调用manager查询
        return messageManager.findCommentList(commentType,pageNum,pageSize);
    }
    //公告
    @GetMapping("/messages/announcements")
    public PageBeanVo announcementList(
            @RequestParam(value = "page",defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pagesize",defaultValue = "10") Integer pageSize
    ){

        return messageManager.announcementList(pageNum,pageSize);
    }
}
